/**
 * 预约建档初始化
 */
var ReservationsRecordTable = {
    id: "ReservationsRecordTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
ReservationsRecordTable.initColumn = function () {
    var columns =
        [
            {field: 'selectItem', radio: true},
            {title: '', field: 'id', visible: false, align: 'center', valign: 'middle'},
            {
                title: '预约号', field: 'reservationsNum', align: 'center', valign: 'middle', width: 120,
                sortable: true
            },
            {
                title: '客户姓名', field: 'customerName', align: 'center', valign: 'middle', sortable: true, width: 120,
                formatter: function (value, row, index) {
                    if (row.department == "电销咨询" || row.department == "公共池") {
                        return "<a href='javascript:;' onclick='ReservationsRecordTable.reservationsNotDetails(" + '"' + row.id + '"' + ")'>" + row.customerName + "</a>"
                    } else {
                        return "<a href='javascript:;' onclick='ReservationsRecordTable.reservationsNotDetail(" + '"' + row.id + '"' + ")'>" + row.customerName + "</a>"
                    }
                },
            },
            {title: '手机号码', field: 'customerPhone', align: 'center', valign: 'middle', sortable: true, width: 135},
            // {title: '到店状态', field: 'status', align: 'center', valign: 'middle',  sortable: true,},
            {title: '预约门诊', field: 'outpatientName', align: 'center', valign: 'middle', sortable: true, width: 120},
            {
                title: '回访状态', field: 'statuss', align: 'center', valign: 'middle', width: 120,
                sortable: true,
                formatter: function (value, row, index) {
                    if (row.status == "到店") {
                        return "<span style='color: green'>" + value + "</span>"
                    } else {
                        return value;
                    }
                }
            },
            {
                title: '预约时间', field: 'appointmentTime', align: 'center', valign: 'middle', sortable: true, width: 120,
                formatter: function (value, row, index) {
                    if (row.huifang == "" || row.huifang == null) {
                        row.huifang = "无回访详情";
                    } else {
                        row.huifang = ",<b>" + "回访详情：" + row.huifang.replace(/\s{2,}/g,"");
                        var reg = /,<b>/g;
                        var regs = /<\/b>/g;
                        row.huifang = row.huifang.replace(reg, '&#10;');
                        row.huifang = row.huifang.replace(regs, ' ');
                    }
                    if (row.oneChannel == "电销部") {
                        return "<span style=' cursor:pointer' title='" + row.huifang + "'  onclick='ReservationsRecordTable.reservationsNotDetails(" + '"' + row.id + '"' + ")'>" + value.substring(0, 19) + "</span>"
                    } else {
                        return "<span style=' cursor:pointer' title='" + row.huifang + "' onclick='ReservationsRecordTable.reservationsNotDetail(" + '"' + row.id + '"' + ")'>" + value.substring(0, 19) + "</span>"
                    }
                }
            },
            {title: '建档人', field: 'archiving', align: 'center', valign: 'middle', sortable: true, width: 120},
            {title: '跟进人', field: 'follower', align: 'center', valign: 'middle', sortable: true, width: 120},
            {title: '部门', field: 'department', align: 'center', valign: 'middle', sortable: true, width: 120},
            {
                title: '建档时间', field: 'filingTime', align: 'center', valign: 'middle', sortable: true, width: 120,
                formatter: function (value, row, index) {
                    return value.substring(0, 19);
                }
            },
            {title: '一级渠道', field: 'oneChannel', align: 'center', valign: 'middle', sortable: true, width: 120},
            {
                title: '二级渠道',
                field: 'twoChannel',
                align: 'center',
                valign: 'middle',
                sortable: true,
                width: 120
            },
            {
                title: '三级渠道',
                field: 'thrChannel',
                align: 'center',
                valign: 'middle',
                sortable: true,
                width: 120
            },
            {title: '回访', field: 'huifang', align: 'center', valign: 'middle', width: 350},
            {
                title: '性别', field: 'customerSex', align: 'center', valign: 'middle', width: 120,
                sortable: true,
                formatter: function (value, row, index) {
                    if (value == 1) {
                        return "男";
                    } else if (value == 2) {
                        return "女"
                    } else {
                        return "未知"
                    }
                }
            },
            {title: '年龄', field: 'customerAge', align: 'center', valign: 'middle', sortable: true, width: 120},
            {
                title: '预约病种',
                field: 'appointmentPayService',
                align: 'center',
                valign: 'middle',
                sortable: true,
                width: 120
            },
            {title: '访问病种', field: 'accessDisease', align: 'center', valign: 'middle', sortable: true, width: 120},
            {title: '关键词', field: 'keyWord', align: 'center', valign: 'middle', sortable: true, width: 120},
            {title: '微信号', field: 'wechatNumber', align: 'center', valign: 'middle', sortable: true, width: 120},
        ]
    return columns;
};

var Time = new Date();
var Year = Time.getFullYear();
var Month = Time.getMonth() + 1;
var Day = Time.getDate();
if (Month < 10) {
    Month = "0" + Month
}
if (Day < 10) {
    Day = "0" + Day
}
var newDate = Year + "-" + Month + "-" + Day;  //今天
var newMonth = Year + "-" + Month;  //本月

var time1 = new Date();
time1.setDate(time1.getDate() - 1);
var year1 = time1.getFullYear();
var month1 = time1.getMonth() + 1;
var day1 = time1.getDate();
if (month1 < 10) {
    month1 = "0" + month1
}
if (day1 < 10) {
    day1 = "0" + day1
}
var yestDate = year1 + "-" + month1 + "-" + day1;  //昨天

var time2 = new Date();
time2.setMonth(time2.getMonth() - 1);
var year2 = time2.getFullYear();
var month2 = time2.getMonth() + 1;
if (month2 < 10) {
    month2 = "0" + month2
}
var lastMonth = year2 + "-" + month2; //上月
/**
 * 查询预约客户列表
 */
ReservationsRecordTable.search = function () {
    ReservationsRecordTable.table.refresh({query: ReservationsRecordTable.formParams()});
    ReservationsRecordTable.tongji();
}

ReservationsRecordTable.getData = function () {
    ReservationsRecordTable.search();
}

// ReservationsRecordTable.suspensionOut = function () {
//     $('#suspension_box').hide();
//     $('#suspension_box').remove();
// };

ReservationsRecordTable.revisitOperation = function (reservationsId) {
    var index = layer.open({
        type: 2,
        title: '回访操作',
        area: ['90%', '90%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/reservations/to_revisitOperation/' + reservationsId
    });
    this.layerIndex = index;
};

ReservationsRecordTable.getFollower = function () {
    var index = layer.open({
        type: 2,
        title: '添加跟进人',
        area: ['90%', '90%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/reservations/to_follower'
    });
    this.layerIndex = index;
};

/**
 * 未到客户详情
 */
ReservationsRecordTable.reservationsNotDetail = function (id) {
    var pageType = $("#pageType").val();
    window.localStorage.setItem("c", pageType);
    var index = layer.open({
        type: 2,
        title: '预约客户详情',
        area: ['100%', '100%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/reservationsNotArrive/to_reservationsNotDetail/' + id
    });
    this.layerIndex = index;
};

ReservationsRecordTable.reservationsNotDetails = function (id) {
    var pageType = $("#pageType").val();
    window.localStorage.setItem("c", pageType);
    var index = layer.open({
        type: 2,
        title: '预约客户详情',
        area: ['100%', '100%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/reservationsNotArrive/to_reservationsNotDetails/' + id
    });
    this.layerIndex = index;
};

ReservationsRecordTable.today = function () {
    document.getElementById("startAppointmentTime").value = newDate + " " + "00:00:00";
    document.getElementById("endAppointmentTime").value = newDate + " " + "23:59:59";
}

ReservationsRecordTable.yesteray = function () {
    document.getElementById("startAppointmentTime").value = yestDate + " " + "00:00:00";
    document.getElementById("endAppointmentTime").value = yestDate + " " + "23:59:59";
}

ReservationsRecordTable.thisMonth = function () {
    var lastDay = 28;
    if (Month == 1 || Month == 3 || Month == 5 || Month == 7 || Month == 8 || Month == 10 || Month == 12) {
        lastDay = 31;
    }
    else if (Month == 4 || Month == 6 || Month == 9 || Month == 11) {
        lastDay = 30;
    }
    document.getElementById("startAppointmentTime").value = newMonth + "-" + "01" + " " + "00:00:00";
    document.getElementById("endAppointmentTime").value = newMonth + "-" + lastDay + " " + "23:59:59";
}

ReservationsRecordTable.lastMonth = function () {
    var lastDay = 28;
    if (month2 == 1 || month2 == 3 || month2 == 5 || month2 == 7 || month2 == 8 || month2 == 10 || month2 == 12) {
        lastDay = 31;
    }
    else if (month2 == 4 || month2 == 6 || month2 == 9 || month2 == 11) {
        lastDay = 30;
    }
    document.getElementById("startAppointmentTime").value = lastMonth + "-" + "01" + " " + "00:00:00";
    document.getElementById("endAppointmentTime").value = lastMonth + "-" + lastDay + " " + "23:59:59";

};

/**
 * 检查是否选中
 */
ReservationsRecordTable.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if (selected.length == 0) {
        Feng.info("请先选中表格中的某一记录！");
        return false;
    } else {
        ReservationsRecordTable.seItem = selected[0];
        return true;
    }
};
//把对象拼接成URL的键值对参数param1=value1&param2=value2
var parseParam = function (param) {
    var paramStr = "";
    $.each(param, function (i) {
        paramStr += '&' + getSingleData(param, i);
    });
    return paramStr.substr(1);
};

var getSingleData = function (param, key) {
    return key + "=" + param[key];
}

/**
 *  新 市场预约表单查询提交参数
 * @returns {{}}
 */
ReservationsRecordTable.formParams = function () {
    var queryData = {};
    queryData['outpatientName'] = $("#outpatientName").val(); //门诊
    queryData['department'] = $("#department").val(); //  部门
    queryData['reach'] = $("#reach").val().trim();  //姓名   电话   微信  预约号
    queryData['appointmentPayService'] = $("#appointmentPayService").val();  //预约项目
    queryData['archiving'] = $("#archiving").val();   //建档人
    queryData['follower'] = $("#follower").val();
    queryData['accessDisease'] = $("#accessDisease").val();  //访问病种
    queryData['oneChannel'] = $("#oneChannel").val();  //一级渠道
    queryData['twoChannel'] = $("#twoChannel").val();    //二级渠道
    queryData['thrChannel'] = $("#thrChannel").val();    //三级渠道
    queryData['wechatNumber'] = $("#wechatNumber").val();   //微信
    queryData['statuss'] = $("#statuss").val();   //状态
    queryData['status'] = $("#status").val();   //状态

    queryData['startFilingTime'] = $("#startFilingTime").val();   //建档时间
    queryData['endFilingTime'] = $("#endFilingTime").val();   //

    var pageType = $("#pageType").val();//空值表示是建档界面，0 未到界面  1已到界面
    if (pageType == '0') {
        //建档
        queryData['startFilingTime'] = $("#startFilingTime").val();  //建档时间
        queryData['endFilingTime'] = $("#endFilingTime").val();
    } else if (pageType == '1') {
        //已到
        queryData['startFirstVisitDate'] = $("#startFirstVisitDate").val();  //建档时间
        queryData['endFirstVisitDate'] = $("#endFirstVisitDate").val();
    } else if (pageType == '2') {
        //未到
        queryData['startAppointmentTime'] = $("#startAppointmentTime").val();  //建档时间
        queryData['endAppointmentTime'] = $("#endAppointmentTime").val();
    }
    queryData['pageType'] = $("#pageType").val();   // 界面参数
    //JSON.stringify() 输出对象的全部内容
    // alert(JSON.stringify(queryData));
    return queryData;
}

/**
 *  新建
 */
ReservationsRecordTable.addToReservations = function () {
    var index = layer.open({
        type: 2,
        title: '添加预约客户',
        area: ['60%', '100%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/reservation/reservations_addTo'
    });
    this.layerIndex = index;
};

/**
 *  选择建档人
 */
ReservationsRecordTable.getArchiving = function () {
    var index = layer.open({
        type: 2,
        title: '选中建档人',
        area: ['90%', '90%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/reservation/to_archiving'
    });
    this.layerIndex = index;
};

/**
 *  导出
 */
ReservationsRecordTable.reservationsExport = function () {
    var queryData = {};
    queryData['outpatientName'] = $("#outpatientName").val(); //门诊
    queryData['department'] = $("#department").val(); //  部门
    queryData['reach'] = $("#reach").val().trim();  //姓名   电话   微信  预约号
    queryData['appointmentPayService'] = $("#appointmentPayService").val();  //预约项目
    queryData['archiving'] = $("#archiving").val();   //建档人
    queryData['follower'] = $("#follower").val();
    queryData['accessDisease'] = $("#accessDisease").val();  //访问病种
    queryData['oneChannel'] = $("#oneChannel").val();  //一级渠道
    queryData['twoChannel'] = $("#twoChannel").val();    //二级渠道
    queryData['thrChannel'] = $("#thrChannel").val();    //三级渠道
    queryData['wechatNumber'] = $("#wechatNumber").val();   //微信
    queryData['statuss'] = $("#statuss").val();   //状态

    queryData['startFilingTime'] = $("#startFilingTime").val();   //建档时间
    queryData['endFilingTime'] = $("#endFilingTime").val();   //
    var pageType = $("#pageType").val();
    if (pageType == '0') {
        //建档
        queryData['status'] = $("#status").val();   //状态
        queryData['startFilingTime'] = $("#startFilingTime").val();  //建档时间
        queryData['endFilingTime'] = $("#endFilingTime").val();
    } else if (pageType == '1') {
        //已到
        queryData['startFirstVisitDate'] = $("#startFirstVisitDate").val();  //建档时间
        queryData['endFirstVisitDate'] = $("#endFirstVisitDate").val();
    } else if (pageType == '2') {
        //未到
        queryData['startAppointmentTime'] = $("#startAppointmentTime").val();  //建档时间
        queryData['endAppointmentTime'] = $("#endAppointmentTime").val();
    }
    queryData['pageType'] = $("#pageType").val();   // 界面参数
    var param = parseParam(queryData);
    location.href = Feng.ctxPath + '/reservation/reservationsExport?' + param;
}

/**
 * 重置
 */
ReservationsRecordTable.resetSearch = function () {
    $("#reach").val("");
    $("#archiving").val("");
    $("#follower").val("");
    $("#accessDisease").val("");
    $("#statuss").val("");
    $("#status").val("");

    // $("#startFilingTime").val("");
    // $("#endFilingTime").val("");
    // document.getElementById("startFilingTime").value = newDate + " " + "00:00:00";
    // document.getElementById("endFilingTime").value = newDate + " " + "23:59:59";

    var pageType = $("#pageType").val();//空值表示是建档界面，0 未到界面  1已到界面
    if (pageType == '0') {
        //建档
        $("#startFilingTime").val("");
        $("#endFilingTime").val("");
        // document.getElementById("startFilingTime").value = newDate + " " + "00:00:00";
        // document.getElementById("endFilingTime").value = newDate + " " + "23:59:59";
    } else if (pageType == '1') {
        //已到
        $("#startFirstVisitDate").val("");
        $("#endFirstVisitDate").val("");
        // document.getElementById("startFirstVisitDate").value = newDate + " " + "00:00:00";
        // document.getElementById("endFirstVisitDate").value = newDate + " " + "23:59:59";
    } else if (pageType == '2') {
        //未到
        $("#startAppointmentTime").val("");
        $("#endAppointmentTime").val("");
        $("#startFilingTime").val("");
        $("#endFilingTime").val("");
        // document.getElementById("startAppointmentTime").value = newDate + " " + "00:00:00";
        // document.getElementById("endAppointmentTime").value = newDate + " " + "23:59:59";
        // document.getElementById("startFilingTime").value = newDate + " " + "00:00:00";
        // document.getElementById("endFilingTime").value = newDate + " " + "23:59:59";
    }

    $("#appointmentPayService").val("");
    $("#oneChannel").val("请选择");
    $("#twoChannel").val("请选择");
    $("#thrChannel").val("请选择");
    $("#outpatientName").val("");
    $("#wechatNumber").val("");
    $("#department").val("");
    ReservationsRecordTable.search();
};

/**
 * 统计建档，已到，未到 人数
 */
ReservationsRecordTable.tongji = function () {
    //获取门诊、部门、建档人参数
    var param1 = $("#outpatientName").val();  //门诊
    var param2 = $("#department").val();   //部门
    var param3 = $("#archiving").val();  //建档人
    var param4 = $("#thrChannel").val(); //三级渠道
    var param5 = $("#twoChannel").val();  //二级渠道
    var param6 = $("#oneChannel").val();  //一级渠道
    var param7 = $("#statuss").val();  //状态
    var param8 = $("#accessDisease").val();  //访问病种
    var param9 = $("#appointmentPayService").val();  //访问项目
    var param10 = $("#status").val();  //状态

    var param11 = $("#follower").val();

    //发送ajax请求后台查询统计信息，赋值到对应的地方
    $.ajax({
        type: "GET",
        url: Feng.ctxPath + "/reservation/tongji",
        data: {
            param1: param1, param2: param2, param3: param3,
            param4: param4, param5: param5, param6: param6,
            param7: param7, param8: param8, param9: param9,
            param10: param10, param11: param11
        },
        dataType: "json",
        success: function (data) {
            var pageType = $("#pageType").val();//空值表示是建档界面，0 未到界面  1已到界面
            if (pageType == '0') {
                //建档
                $("#dengjiToday").html(data[0].countNum);
                $("#dengjiYesterday").html(data[3].countNum);
                $("#dengjiMonth").html(data[6].countNum);
                $("#dengjiLastMonth").html(data[9].countNum);
            } else if (pageType == '1') {
                //已到
                $("#daozhenToday").html(data[1].countNum);
                $("#daozhenYesterday").html(data[4].countNum);
                $("#daozhenMonth").html(data[7].countNum);
                $("#daozhenLastMonth").html(data[10].countNum);
            } else if (pageType == '2') {
                //未到
                $("#weidaoToday").html(data[2].countNum);
                $("#weidaoYesterday").html(data[5].countNum);
                $("#weidaoMonth").html(data[8].countNum);
                $("#weidaoLastMonth").html(data[11].countNum);
            }
        }
    });
}


$(function () {

    $.post(Feng.ctxPath + "/payService/getList", function (data) {
        var txt = '<option value="">全部</option>';
        for (var i = 0; i < data.length; i++) {
            txt += '<option value="' + data[i].department + '">' + data[i].department + '</option>';
        }
        document.getElementById('appointmentPayService').innerHTML = txt;
        //状态单选
        var seletepayservicename = $('#payservicenameValue').val();
        if (seletepayservicename != "") {
            $("#appointmentPayService option[value=" + seletepayservicename + "]").attr("selected", "selected");
        }
    }, "json");

    var pageType = $("#pageType").val();//空值表示是建档界面，0 未到界面  1已到界面
    if (pageType == '0') {
        //  建档 (默认结束建档时间)
        document.getElementById("startFilingTime").value = newDate + " " + "00:00:00";
        document.getElementById("endFilingTime").value = newDate + " " + "23:59:59";
    } else if (pageType == '1') {
        //  已到 (默认结束 首次到店时间)
        document.getElementById("startFirstVisitDate").value = newDate + " " + "00:00:00";
        document.getElementById("endFirstVisitDate").value = newDate + " " + "23:59:59";
    } else if (pageType == '2') {
        // 未到 (默认结束 首次到店时间)
        document.getElementById("startAppointmentTime").value = newDate + " " + "00:00:00";
        document.getElementById("endAppointmentTime").value = newDate + " " + "23:59:59";
        document.getElementById("startFilingTime").value = newDate + " " + "00:00:00";
        document.getElementById("endFilingTime").value = newDate + " " + "23:59:59";
    }

    //加载表格数据
    var defaultColunms = ReservationsRecordTable.initColumn();
    var table = new BSTable(ReservationsRecordTable.id, "/reservation/list", defaultColunms);
    table.setPaginationType("server");
    table.setQueryParams(ReservationsRecordTable.formParams());
    ReservationsRecordTable.table = table.init();
    //初始化统计数据
    ReservationsRecordTable.search();

    var menuName = $("#menuName").val();
    $.ajax({
        url: Feng.ctxPath + "/reservation/reservation_initialization",
        type: "post",
        data: {
            "menuName": menuName
        },
        success: function (data) {
            if(data != ""){
                var item = data.listx1.split("，");
                for(var i = 0 ; i < item.length ; i++){
                    $('#ReservationsRecordTable').bootstrapTable('hideColumn', item[i]);
                }
            }
        }
    });


    //初始化下拉项目列表
    $.post(Feng.ctxPath + "/payService/getList", function (data) {
        var txt = '<option value="">全部</option>';
        for (var i = 0; i < data.length; i++) {
            txt += '<option value="' + data[i].department + '">' + data[i].department + '</option>';
        }
        document.getElementById('appointmentPayService').innerHTML = txt;
        //状态单选
        var seletepayservicename = $('#payservicenameValue').val();
        if (seletepayservicename != "") {
            $("#appointmentPayService option[value=" + seletepayservicename + "]").attr("selected", "selected");
        }
    }, "json");

    //初始化下拉到店门诊列表
    $.post(Feng.ctxPath + "/outpatientManagement/getList", function (data) {
        var txt = '<option value="">全部</option>';
        for (var i = 0; i < data.length; i++) {
            txt += '<option value="' + data[i].simplename + '">' + data[i].simplename + '</option>';
        }
        document.getElementById('outpatientName').innerHTML = txt;
        //状态单选
        var seleteooutpatientName = $('#outpatientNameValue').val();
        if (seleteooutpatientName != "") {
            $("#outpatientName option[value=" + seleteooutpatientName + "]").attr("selected", "selected");
        }
    }, "json");

    //采用定时器监听 时间内容是否变化
    var oldStartValue1 = $("#startFilingTime").val();
    var oldEndtimeValue1 = $("#endFilingTime").val();

    var oldStartValue2 = $("#startFirstVisitDate").val();
    var oldEndtimeValue2 = $("#endFirstVisitDate").val();

    var oldStartValue3 = $("#startAppointmentTime").val();
    var oldEndtimeValue3 = $("#endAppointmentTime").val();

    var oldArchivingValue = $("#archiving").val();
    var oldFollowerValue = $("#follower").val();

    var oldOneChannelValue = $("#oneChannel").val();
    var oldTwoChannelValue = $("#twoChannel").val();
    var oldThrChannelValue = $("#thrChannel").val();
    setInterval(
        function () {//定时执行方法内容
            if ($("#startFilingTime").val() != oldStartValue1 || $("#endFilingTime").val
                () != oldEndtimeValue1) {//如果时间发生变化，就触发查询事件
                ReservationsRecordTable.search();
                //如果值发生变化之后，把最新的值赋值到老的变量里面
                oldStartValue1 = $("#startFilingTime").val();
                oldEndtimeValue1 = $("#endFilingTime").val();
            }
            if ($("#startFirstVisitDate").val() != oldStartValue2 ||
                $("#endFirstVisitDate").val() != oldEndtimeValue2) {//如果时间发生变化，就触发查询事件
                ReservationsRecordTable.search();
                //如果值发生变化之后，把最新的值赋值到老的变量里面
                oldStartValue2 = $("#startFirstVisitDate").val();
                oldEndtimeValue2 = $("#endFirstVisitDate").val();
            }
            if ($("#startAppointmentTime").val() != oldStartValue3 ||
                $("#endAppointmentTime").val() != oldEndtimeValue3) {//如果时间发生变化，就触发查询事件
                ReservationsRecordTable.search();
                //如果值发生变化之后，把最新的值赋值到老的变量里面
                oldStartValue3 = $("#startAppointmentTime").val();
                oldEndtimeValue3 = $("#endAppointmentTime").val();
            }
            if (oldArchivingValue != $("#archiving").val()) {
                ReservationsRecordTable.search();
                oldArchivingValue = $("#archiving").val();//每次判断为修改后把最新的文本框的值给原有变量，为下一次循坏执行方法体里面的判断做准备
            }

            if (oldFollowerValue != $("#follower").val()) {
                ReservationsRecordTable.search();
                oldFollowerValue = $("#follower").val();//每次判断为修改后把最新的文本框的值给原有变量，为下一次循坏执行方法体里面的判断做准备
            }

            if ($("#oneChannel").val() != oldOneChannelValue || $("#oneChannel").val() != oldOneChannelValue) {//如果时间发生变化，就触发查询事件
                ReservationsRecordTable.search();
                //如果值发生变化之后，把最新的值赋值到老的变量里面
                oldOneChannelValue = $("#oneChannel").val();
            }
            if ($("#twoChannel").val() != oldTwoChannelValue || $("#twoChannel").val() != oldTwoChannelValue) {//如果时间发生变化，就触发查询事件
                ReservationsRecordTable.search();
                //如果值发生变化之后，把最新的值赋值到老的变量里面
                oldTwoChannelValue = $("#twoChannel").val();
            }
            if ($("#thrChannel").val() != oldThrChannelValue || $("#thrChannel").val() != oldThrChannelValue) {//如果时间发生变化，就触发查询事件
                ReservationsRecordTable.search();
                //如果值发生变化之后，把最新的值赋值到老的变量里面
                oldThrChannelValue = $("#thrChannel").val();
            }

        }, 500);

});
